<!--提交工单界面-->


<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>提交工单</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="icon" href="__STATIC__/admin/images/favicon.ico">
    <link rel="stylesheet" href="__STATIC__/admin/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="__STATIC__/admin/css/public.css" media="all">
    <link rel="stylesheet" href="__STATIC__/admin/js/lay-module/step-lay/step.css" media="all">
    {include file="public/jquery"}
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <div class="layui-fluid">
            <div class="layui-card">
                <div class="layui-card-body" style="padding-top: 40px;">
                    <div class="layui-carousel" id="stepForm" lay-filter="stepForm" style="margin: 0 auto;">
                        <div carousel-item>
                            <div>
                                <form class="layui-form" style="margin: 0 auto;max-width: 460px;padding-top: 40px;">
                                    
                                   <div class="layui-form-item">
                                        <label class="layui-form-label">问题类型:</label>
                                        <div class="layui-input-block">
                                            <select lay-verify="required" name="type" id="type">
                                                <option value="服务器问题" selected>服务器问题</option>
                                                <option value="交易问题">交易问题</option>
                                                <option value="其它问题">其它问题</option>
                                            </select>
                                        </div>
                                    </div>

                                    <div class="layui-form-item">
                                        <label class="layui-form-label">问题描述:</label>
                                        <div class="layui-input-block">
                                            <textarea name="describe" placeholder="简单描述一下你遇到的问题" value="" class="layui-textarea"></textarea>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-input-block">
                                            <button class="layui-btn" lay-submit lay-filter="formStep">
                                                &emsp;下一步&emsp;
                                            </button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <div>
                                <form class="layui-form" style="margin: 0 auto;max-width: 460px;padding-top: 40px;">
                                      <div class="layui-form-item">
                                        <label class="layui-form-label">平台账号</label>
                                        <div class="layui-input-block">
                                          <input type="text" name="username" id="username" placeholder="请输入平台账号" autocomplete="off" class="layui-input">
                                        </div>
                                      </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">平台密码</label>
                                        <div class="layui-input-block">
                                          <input type="text" name="password" id="password" placeholder="请输入平台密码" autocomplete="off" class="layui-input">
                                        </div>
                                      </div>
                                    <div class="layui-form-item">
                                        <div class="layui-input-block">
                                            <button type="button" class="layui-btn layui-btn-primary pre">上一步</button>
                                            <button class="layui-btn" lay-submit lay-filter="formStep2" onclick="">
                                                &emsp;确认提交&emsp;
                                            </button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <div>
                                <div style="text-align: center;margin-top: 90px;">
                                    <i class="layui-icon layui-circle"
                                       style="color: white;font-size:30px;font-weight:bold;background: #52C41A;padding: 20px;line-height: 80px;">&#xe605;</i>
                                    <div style="font-size: 24px;color: #333;font-weight: 500;margin-top: 30px;">
                                        提交成功
                                    </div>
                                    <div style="font-size: 14px;color: #666;margin-top: 20px;">请耐心等待客服回复</div>
                                    <div style="font-size: 14px;color: #666;margin-top: 20px;">工单编号：<b id="won"></b></div>
                                </div>
                                <div style="text-align: center;margin-top: 50px;">
                                    <button class="layui-btn layui-btn-primary" onclick="jump_look()">查看工单</button>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                </div>
            </div>
        </div>

    </div>
</div>
<script src="__STATIC__/admin/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="__STATIC__/admin/js/lay-config.js?v=2.0.0" charset="utf-8"></script>
<script>
    let describe = '';
    let type = '';
    let kid = '';
    let wkid = '';
    layui.use([ 'form', 'step'], function () {
        var $ = layui.$,
            form = layui.form,
            step = layui.step;

        step.render({
            elem: '#stepForm',
            filter: 'stepForm',
            width: '100%', //设置容器宽度
            stepWidth: '750px',
            height: '500px',
            stepItems: [{
                title: '填写信息'
            }, {
                title: '账户信息'
            }, {
                title: '完成'
            }]
        });


        form.on('submit(formStep)', function (data) {
            console.log(data.field)
            if(!data.field.describe || !data.field.type){
                layer.msg('请检测表单完整性')
                return;
            }
            
            describe = data.field.describe
            type = data.field.type
            
            step.next('#stepForm');
            return false;
        });
        

        form.on('submit(formStep2)', function (data) {
           // console.log(describe,type)
           var username = data.field.username;
           var password = data.field.password;
           
            if(!username || !password){
                layer.msg('请检测表单完整性')
                return;
            }
          
           $.post('/add_mysql_work_order',{'type':type,'describe':describe,'username':username,'password':password},function(res){
               if(res.code>0){
                 layer.msg(res.msg)  
               }else{
                 step.next('#stepForm');
                 layer.msg(res.msg)  
                 
                 $('#won').text(res.won);
                 kid = res.won;
                 wkid = res.wkid;
               }
           },'json');
            //step.next('#stepForm');
            return false;
        });

        $('.pre').click(function () {
            step.pre('#stepForm');
        });

        $('.next').click(function () {
            step.next('#stepForm');
        });
    })
    
    function jump_look(){
        layer.open({
          title:'工单 #' + kid,
          type: 2,
          shade: false,
          area: ['100%', '100%'],
          maxmin: true,
          content: '/work_order_page/id/' + wkid +'/#footerMsg',
          zIndex: layer.zIndex, //重点1
          success: function(layero){
            layer.setTop(layero); //重点2
          }
        });  
    }
</script>
</body>
</html>